# this file should be named serverside.app

ServerSide::Application.create do
  configure(
    :template_directory => 'views',
    :server_ports => 8000..8009,
    :mime_types => {'.svg' => 'image/svg+xml'}
  )

  error_pages {|s| serve_file("/static/errors/#{s}"}
  
  route(:host => /(.+)\.reality-scada/) {|r| r.path = $1/r.path}
  
  route :path => '/static', :directory => 'static/public',
    :cache_max_age => 30.days
  route :path => '/', :file => 'static.public/index.html',
    :cache_max_age => 30.days
end

class TimeController < Reality.mount {path == '/time'}
  def process
    @time = Time.now
    render_template 'time'
  end
end

Reality.templates.add('time', <<EOF
<html>
  <head>
  </head>
  <body>
    <h2>The current time is: <%= @time %></h2>
  </body>
</html>
EOF)

###########################################################################

# to control the server:

serverside start/stop/console

